<template>
  <div v-show="gameinfo.has_coupon === 1">
    <ul class="game_coupon" @click="$router.push('/gameinfo/coupon')">
      <li class="coupon_item" v-for="(item, index) in list" :key="index">
        <div class="coupon_item_left">
          <div>
            <span style="font-size: .346667rem;">¥</span>
            <span class="amount_text">{{item.amount}}</span>
          </div>
          <div style="font-size: .266667rem;">
            <span v-if="item.use_cdt === '单笔满1元可用'">无门槛</span>
            <span v-else>满减券</span>
          </div>
        </div>
        <div class="coupon_item_right">
          <div>领</div>
          <div>取</div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: {
    gameinfo: {
      type: Object,
      default() {
        return {}
      }
    },
  },
  data() {
    return {
      couponList: [],
    }
  },
  created () {
    this.getCoupon();
  },
  methods: {
    getCoupon() {
      this.axios.get('/detail_coupon_5546.json',{}).then(res => {
        this.couponList = res.data.list
      })
    }
  },
  computed: {
    list() {
      if(this.couponList.length <= 3 && this.couponList !== null) {
        return this.couponList
      }else {
        return this.couponList.slice(0,3)
      }
    }
  },
}
</script>

<style lang="less" scoped>
.game_coupon {
  box-sizing: border-box;
  width: 10rem;
  height: 1.6rem;
  background: #fff;
  padding: 0 .426667rem .266667rem;
  display: flex;
  justify-content: space-between;
}

.coupon_item {
  position: relative;
  width: 2.746667rem;
  height: 1.333333rem;
  background: linear-gradient(134deg, #FFAC58 0%, #FF4600 100%);
  border-radius: .133333rem;
  font-size: .32rem;
  color: #fff;
  display: flex;
  justify-content: space-around;
  .coupon_item_left {
    width: 2.04rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: .013333rem dashed #fff;
    .amount_text {
      font-size: .8rem;
      line-height: .8rem;
      font-weight: bold;
    }
  }
  .coupon_item_right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: .346667rem;
    line-height: .48rem;
  }
}
</style>